#ifndef __XTABLE_H__
#define __XTABLE_H__

#include "math/xvalue.h"
#include "math/vector.hpp"
#include <map>

NS_MATH_BEGIN

class xtable : public XObjectData
{
public:
	bool exist(const xstring& name) const;
	bool del(const xstring& name);

	void clear();
	idtype size() const;

	template<typename T>
	bool add(const xstring& name, const T& val)
	{
		if(exist(name))
		{
			return false;
		}

		XValue v;
		v.SetValue<T>(val);
		m_map[name] = v;

		return true;
	}

	template<typename T>
	bool add(const xstring& name, T& val)
	{
		if(exist(name))
		{
			return false;
		}

		XValue v;
		v.SetValue<T>(val);
		m_map[name] = v;

		return true;
	}

	template<>
	bool add<XValue>(const xstring& name, XValue& val);


	XValue& operator[](const xstring& name);

	vector<xstring> keys()const;	// return all variable names



protected:
	std::map<xstring, XValue> m_map;
};


NS_MATH_END
#endif